import warnings
warnings.filterwarnings('ignore')
## Get data
from dataframes import final_df_dict
from sympy import *
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
from ipywidgets import Output
from tqdm import tqdm
df = final_df_dict['decision'].copy()
df.dropna(inplace=True)
df430_pre = df[(df['participant.inflation'] == '430') & (df['participant.day'] < 3)]
df1012_pre = df[(df['participant.inflation'] == '1012') & (df['participant.day'] < 3)]
df430_post = df[(df['participant.inflation'] == '430') & (df['participant.day'] >= 3)]
df1012_post = df[(df['participant.inflation'] == '1012') & (df['participant.day'] >= 3)]
dfs = {'430_pre': df430_pre,
'1012_pre': df1012_pre,
'430_post': df430_post,
'1012_post': df1012_post}
## Calculate average value for each month
quantity_430_pre = np.array([])
quantity_1012_pre = np.array([])
quantity_430_post = np.array([])
quantity_1012_post = np.array([])
quantities = {}
for k, v in dfs.items():
quantities[k] = np.array([])
for n in range(1,121):
quantities[k] = np.append(quantities[k], v[f'task.{n}.player.decision'].mean())
# quantity_430_pre = np.append(quantity_430_pre, df430_pre[f'task.{n}.player.decision'].mean())
# quantity_1012_pre = np.append(quantity_1012_pre, df1012_pre[f'task.{n}.player.decision'].mean())
# quantity_430_post = np.append(quantity_430_post, df430_post[f'task.{n}.player.decision'].mean())
# quantity_1012_post = np.append(quantity_1012_post, df1012_post[f'task.{n}.player.decision'].mean())
# qs = [quantity_430_pre,quantity_1012_pre,quantity_430_post,quantity_1012_post,]
# for i in range(len(qs)):
# for n in range(1,121):
# qs[i] = np.append(qs[i], dfs[i][f'task.{n}.player.decision'].mean())
# print('quantity', len(quantity_430_pre), type(quantity_430_pre))
months = np.array([n for n in range(1,121)])
for k, v in quantities.items():
plt.errorbar(months, v, 0.3, fmt='o', label=k)
plt.legend(
loc="upper right",
)
# label=[
# '430_pre',
# '1012_pre',
# '430_post',
# '1012_post',
<matplotlib.legend.Legend at 0x24230a8e700>
df = final_df_dict['decision'].copy()
df.dropna(inplace=True)
cols430 = ['task.29.player.decision','task.30.player.decision','task.31.player.decision','task.32.player.decision',
'task.59.player.decision','task.60.player.decision','task.61.player.decision','task.62.player.decision',
'task.89.player.decision','task.90.player.decision','task.91.player.decision','task.92.player.decision',]
cols1012 = ['task.11.player.decision','task.12.player.decision','task.13.player.decision','task.14.player.decision',
'task.35.player.decision','task.36.player.decision','task.37.player.decision','task.38.player.decision',
'task.59.player.decision','task.60.player.decision','task.61.player.decision','task.62.player.decision',
'task.83.player.decision','task.84.player.decision','task.85.player.decision','task.86.player.decision',
'task.107.player.decision','task.108.player.decision','task.109.player.decision','task.110.player.decision',]
df430_pre = df[cols430][(df['participant.inflation'] == '430') & (df['participant.day'] < 3)]
df1012_pre = df[cols1012][(df['participant.inflation'] == '1012') & (df['participant.day'] < 3)]
df430_post = df[cols430][(df['participant.inflation'] == '430') & (df['participant.day'] >= 3)]
df1012_post = df[cols1012][(df['participant.inflation'] == '1012') & (df['participant.day'] >= 3)]
dfs = {'430_pre': df430_pre,
'1012_pre': df1012_pre,
'430_post': df430_post,
'1012_post': df1012_post}
# for k, v in dfs.items():
# plt.hist(v)
# plt.hist(df430_pre, df430_post)
# df430_post
plt.hist([df430_pre[cols430[1+1]],df430_post[cols430[1+1]],df430_pre[cols430[2+1]],
df430_post[cols430[2+1]]], alpha=0.5, label=['430_pre 31','430_post 31',
'430_pre 32','430_post 32'])
# plt.bar_label([df430_pre,df430_post], fontsize=20, color='navy')
# plt.hist(df430_post, alpha=0.5, label='430_post')
plt.legend(loc='upper right')
plt.show()
plt.hist([df430_pre[cols430[5+1]],df430_post[cols430[5+1]],df430_pre[cols430[6+1]],
df430_post[cols430[6+1]]], alpha=0.5, label=['430_pre 61','430_post 61',
'430_pre 62','430_post 62'])
# plt.bar_label([df430_pre,df430_post], fontsize=20, color='navy')
# plt.hist(df430_post, alpha=0.5, label='430_post')
plt.legend(loc='upper right')
plt.show()
plt.hist([df430_pre[cols430[10]],df430_post[cols430[10]],df430_pre[cols430[11]],
df430_post[cols430[11]]], alpha=0.5, label=['430_pre 91','430_post 91',
'430_pre 92','430_post 92'])
# plt.bar_label([df430_pre,df430_post], fontsize=20, color='navy')
# plt.hist(df430_post, alpha=0.5, label='430_post')
plt.legend(loc='upper right')
plt.show()
plt.hist([df1012_pre[cols1012[1]],df1012_post[cols1012[1]],df1012_pre[cols1012[2]],
df1012_post[cols1012[2]]], alpha=0.5, label=['1012_pre 12','1012_post 12',
'1012_pre 13','1012_post 13'])
plt.legend(loc='upper right')
plt.show()
(442, 126) (442, 126) (117, 12) (115, 20) (105, 12) (105, 20)
est = final_df_dict['inf_estimate'].copy()
inf_1012 = [0.45, 60.79, 0.45, 60.79, 0.45, 60.79, 0.45, 60.79, 0.45, 60.79]
inf_430 = [0.38, 0.47, 26.85, 55.49, 64.18, 0.38, 0.47, 26.85, 55.49, 64.18]
rev_1012 = [x[1] - x[0] for x in zip(inf_1012, inf_1012[1:])]
rev_430 = [x[1] - x[0] for x in zip(inf_430, inf_430[1:])]
for n in range(2,11):
est[f'{12 * n}-{12 * (n - 1)}'] = est[f'task.{n * 12}.player.inf_estimate'] -\
est[f'task.{(n - 1) * 12}.player.inf_estimate']
est['revisions'] = np.nan
for i in range(len(est)):
x = 0
for n in range(2,11):
if est[f'{12 * n}-{12 * (n - 1)}'].iloc[i] != 0:
x += 1
else:
pass
est['revisions'].iloc[i] = x
## Graph estimates
cols = [c for c in est.columns.to_list() if ('task.' in c)]
fig, ax = plt.subplots(figsize=(24, 10))
## Actual inflation
## 10x12 pre
df = est[cols][
(est['participant.inflation'] == '1012') & (est['participant.day'] < 3) & (
est['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '10x12 pre'
df.columns = df_cols
df.plot(ax=ax, color='r', alpha=0.1)
# ax.get_legend().remove()
## 10x12 post
df = est[cols][
(est['participant.inflation'] == '1012') & (est['participant.day'] >= 3) & (
est['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '10x12 post'
df.columns = df_cols
df.plot(ax=ax, color='b', alpha=0.1)
# ax.get_legend().remove()
plt.axhline(y=60.79, color='g', linestyle=':', label='max inflation')
plt.axhline(y=0, color='black', linestyle='-')
plt.plot(inf_1012, color='#f2f542', linewidth=4, label='actual inflation')
plt.legend(loc = 'upper left')
plt.title('10x12 perceptions')
fig, ax = plt.subplots(figsize=(24, 10))
## 4x30 pre
df = est[cols][
(est['participant.inflation'] == '430') & (est['participant.day'] < 3) & (
est['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '4x30 pre'
df.columns = df_cols
df.plot(ax=ax, color='r', alpha=0.1)
# ax.get_legend().remove()
## 4x30 post
df = est[cols][
(est['participant.inflation'] == '430') & (est['participant.day'] >= 3) & (
est['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '4x30 post'
df.columns = df_cols
df.plot(ax=ax, color='b', alpha=0.1)
# ax.get_legend().remove()
plt.axhline(y=64.18, color='g', linestyle=':', label='max inflation')
plt.axhline(y=0, color='black', linestyle='-')
plt.plot(inf_430, color='#f2f542', linewidth=4, label='actual inflation')
plt.legend(loc = 'upper left')
plt.title('4x30 perceptions')
## Graph revisions
cols = [c for c in est.columns.to_list() if ('-' in c)]
fig, ax = plt.subplots(figsize=(24, 10))
## 10x12 pre
df = est[cols][
(est['participant.inflation'] == '1012') & (est['participant.day'] < 3) & (
est['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '10x12 pre'
df.columns = df_cols
df.plot(ax=ax, color='r', alpha=0.1)
# ax.get_legend().remove()
## 10x12 post
df = est[cols][
(est['participant.inflation'] == '1012') & (est['participant.day'] >= 3) & (
est['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '10x12 post'
df.columns = df_cols
df.plot(ax=ax, color='b', alpha=0.1)
# ax.get_legend().remove()
plt.axhline(y=60.79, color='g', linestyle=':', label='max inflation')
plt.axhline(y=0, color='black', linestyle='-')
plt.plot(rev_1012, color='#f2f542', linewidth=4, label='correct revision')
plt.legend(loc = 'upper left')
plt.title('10x12 revisions')
fig, ax = plt.subplots(figsize=(24, 10))
## 4x30 pre
df = est[cols][
(est['participant.inflation'] == '430') & (est['participant.day'] < 3) & (
est['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '4x30 pre'
df.columns = df_cols
df.plot(ax=ax, color='r', alpha=0.1)
# ax.get_legend().remove()
## 4x30 post
df = est[cols][
(est['participant.inflation'] == '430') & (est['participant.day'] >= 3) & (
est['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '4x30 post'
df.columns = df_cols
df.plot(ax=ax, color='b', alpha=0.1)
# ax.get_legend().remove()
plt.axhline(y=64.18, color='g', linestyle=':', label='max inflation')
plt.axhline(y=0, color='black', linestyle='-')
plt.plot(rev_430, color='#f2f542', linewidth=4, label='correct revision')
plt.legend(loc = 'upper left')
plt.title('4x30 revisions')
Text(0.5, 1.0, '4x30 revisions')
def fft_row_magnitudes(row):
fft = np.fft.fft(row)
magnitudes = np.abs(fft)
# power_spectrum = np.abs(fft)**2
est['estimate'] = ''
## Create columns for lists of estimates
for i in range(len(est)):
estimate = est.iloc[i].to_list()
estimate = estimate[6:15]
# ## Convert stock values to int
# stock = [int(i) for i in stock]
est['estimate'].iloc[i] = estimate
est['fft_magnitudes'] = ''
for i in range(len(est)):
fft = np.fft.fft(est['estimate'].iloc[i])
est['fft_magnitudes'].iloc[i] = np.abs(fft)
# power_spectrum = np.abs(fft)**2
# est['fft_magnitudes'] = est['estimate'].apply(fft_row_magnitudes)
## Frequencies of each curve
N = len(est['fft_magnitudes'].iloc[1]) # length of the magnitude list
sampling_rate = 1 # assuming a sampling rate of 1
frequencies = [(i / N) * sampling_rate for i in range(N)]
periodicities = [1 / i for i in frequencies if i != 0]
print(frequencies, len(frequencies))
print(periodicities, len(frequencies))
N = len(est['fft_magnitudes'].iloc[2]) # length of the magnitude list
sampling_rate = 1 # assuming a sampling rate of 1
frequencies = [(i / N) * sampling_rate for i in range(N)]
periodicities = [1 / i for i in frequencies if i != 0]
print(frequencies, len(frequencies))
print(periodicities, len(frequencies))
[0.0, 0.1111111111111111, 0.2222222222222222, 0.3333333333333333, 0.4444444444444444, 0.5555555555555556, 0.6666666666666666, 0.7777777777777778, 0.8888888888888888] 9 [9.0, 4.5, 3.0, 2.25, 1.7999999999999998, 1.5, 1.2857142857142856, 1.125] 9 [0.0, 0.1111111111111111, 0.2222222222222222, 0.3333333333333333, 0.4444444444444444, 0.5555555555555556, 0.6666666666666666, 0.7777777777777778, 0.8888888888888888] 9 [9.0, 4.5, 3.0, 2.25, 1.7999999999999998, 1.5, 1.2857142857142856, 1.125] 9
cols = [c for c in est.columns.to_list() if ('task.' in c)]
fig, ax = plt.subplots(figsize=(20,20))
df1 = est[cols][(est['participant.inflation'] == '430') & (
est['participant.day'] < 3
)]
df1.hist(ax=ax, color='r', label='pre')
fig, ax = plt.subplots(figsize=(20,20))
# ax = fig.gca()
df2 = est[cols][(est['participant.inflation'] == '430') & (
est['participant.day'] >= 3
)]
df2.hist(ax=ax, color='b', label='post')
# ax.legend(loc='upper right')
# plt.show()
fig, ax = plt.subplots(figsize=(20,20))
df1 = est[cols][(est['participant.inflation'] == '1012') & (
est['participant.day'] < 3
)]
df1.hist(ax=ax, color='r', label='pre')
fig, ax = plt.subplots(figsize=(20,20))
# ax = fig.gca()
df2 = est[cols][(est['participant.inflation'] == '1012') & (
est['participant.day'] >= 3
)]
df2.hist(ax=ax, color='b', label='post')
array([[<AxesSubplot:title={'center':'task.12.player.inf_estimate'}>,
<AxesSubplot:title={'center':'task.24.player.inf_estimate'}>,
<AxesSubplot:title={'center':'task.36.player.inf_estimate'}>],
[<AxesSubplot:title={'center':'task.48.player.inf_estimate'}>,
<AxesSubplot:title={'center':'task.60.player.inf_estimate'}>,
<AxesSubplot:title={'center':'task.72.player.inf_estimate'}>],
[<AxesSubplot:title={'center':'task.84.player.inf_estimate'}>,
<AxesSubplot:title={'center':'task.96.player.inf_estimate'}>,
<AxesSubplot:title={'center':'task.108.player.inf_estimate'}>],
[<AxesSubplot:title={'center':'task.120.player.inf_estimate'}>,
<AxesSubplot:>, <AxesSubplot:>]], dtype=object)
exp = final_df_dict['inf_expectation'].copy()
inf_1012 = [60.79, 0.45, 60.79, 0.45, 60.79, 0.45, 60.79, 0.45, 60.79]
inf_430 = [0.47, 26.85, 55.49, 64.18, 0.38, 0.47, 26.85, 55.49, 64.18]
rev_1012 = [x[1] - x[0] for x in zip(inf_1012, inf_1012[1:])]
rev_430 = [x[1] - x[0] for x in zip(inf_430, inf_430[1:])]
for n in range(2,10):
exp[f'{12 * n}-{12 * (n - 1)}'] = exp[f'task.{n * 12}.player.inf_expectation'] -\
exp[f'task.{(n - 1) * 12}.player.inf_expectation']
exp['revisions'] = np.nan
for i in range(len(exp)):
x = 0
for n in range(2,10):
if exp[f'{12 * n}-{12 * (n - 1)}'].iloc[i] != 0:
x += 1
else:
pass
exp['revisions'].iloc[i] = x
## Graph expimates
cols = [c for c in exp.columns.to_list() if ('task.' in c)]
fig, ax = plt.subplots(figsize=(24, 10))
## Actual inflation
## 10x12 pre
df = exp[cols][
(exp['participant.inflation'] == '1012') & (exp['participant.day'] < 3) & (
exp['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '10x12 pre'
df.columns = df_cols
df.plot(ax=ax, color='r', alpha=0.1)
# ax.get_legend().remove()
## 10x12 post
df = exp[cols][
(exp['participant.inflation'] == '1012') & (exp['participant.day'] >= 3) & (
exp['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '10x12 post'
df.columns = df_cols
df.plot(ax=ax, color='b', alpha=0.1)
# ax.get_legend().remove()
plt.axhline(y=60.79, color='g', linestyle=':', label='max inflation')
plt.axhline(y=0, color='black', linestyle='-')
plt.plot(inf_1012, color='#f2f542', linewidth=4, label='actual inflation')
plt.legend(loc = 'upper left')
plt.title('10x12 expectations')
fig, ax = plt.subplots(figsize=(24, 10))
## 4x30 pre
df = exp[cols][
(exp['participant.inflation'] == '430') & (exp['participant.day'] < 3) & (
exp['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '4x30 pre'
df.columns = df_cols
df.plot(ax=ax, color='r', alpha=0.1)
# ax.get_legend().remove()
## 4x30 post
df = exp[cols][
(exp['participant.inflation'] == '430') & (exp['participant.day'] >= 3) & (
exp['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '4x30 post'
df.columns = df_cols
df.plot(ax=ax, color='b', alpha=0.1)
# ax.get_legend().remove()
plt.axhline(y=64.18, color='g', linestyle=':', label='max inflation')
plt.axhline(y=0, color='black', linestyle='-')
plt.plot(inf_430, color='#f2f542', linewidth=4, label='actual inflation')
plt.legend(loc = 'upper left')
plt.title('4x30 expectations')
## Graph revisions
cols = [c for c in exp.columns.to_list() if ('-' in c)]
fig, ax = plt.subplots(figsize=(24, 10))
## 10x12 pre
df = exp[cols][
(exp['participant.inflation'] == '1012') & (exp['participant.day'] < 3) & (
exp['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '10x12 pre'
df.columns = df_cols
df.plot(ax=ax, color='r', alpha=0.1)
# ax.get_legend().remove()
## 10x12 post
df = exp[cols][
(exp['participant.inflation'] == '1012') & (exp['participant.day'] >= 3) & (
exp['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '10x12 post'
df.columns = df_cols
df.plot(ax=ax, color='b', alpha=0.1)
# ax.get_legend().remove()
plt.axhline(y=60.79, color='g', linestyle=':', label='max inflation')
plt.axhline(y=0, color='black', linestyle='-')
plt.plot(rev_1012, color='#f2f542', linewidth=4, label='actual inflation')
plt.legend(loc = 'upper left')
plt.title('10x12 revisions')
fig, ax = plt.subplots(figsize=(24, 10))
## 4x30 pre
df = exp[cols][
(exp['participant.inflation'] == '430') & (exp['participant.day'] < 3) & (
exp['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '4x30 pre'
df.columns = df_cols
df.plot(ax=ax, color='r', alpha=0.1)
# ax.get_legend().remove()
## 4x30 post
df = exp[cols][
(exp['participant.inflation'] == '430') & (exp['participant.day'] >= 3) & (
exp['revisions'] >= 0
)
].T
df_cols = ['_' + str(col) for col in df.columns]
df_cols[0] = '4x30 post'
df.columns = df_cols
df.plot(ax=ax, color='b', alpha=0.1)
# ax.get_legend().remove()
plt.axhline(y=64.18, color='g', linestyle=':', label='max inflation')
plt.axhline(y=0, color='black', linestyle='-')
plt.plot(rev_430, color='#f2f542', linewidth=4, label='actual inflation')
plt.legend(loc = 'upper left')
plt.title('4x30 revisions')
Text(0.5, 1.0, '4x30 revisions')
cols = [c for c in exp.columns.to_list() if ('task.' in c)]
fig, ax = plt.subplots(figsize=(20,20))
df1 = exp[cols][(exp['participant.inflation'] == '430') & (
exp['participant.day'] < 3
)]
df1.hist(ax=ax, color='r', label='pre')
fig, ax = plt.subplots(figsize=(20,20))
# ax = fig.gca()
df2 = exp[cols][(exp['participant.inflation'] == '430') & (
exp['participant.day'] >= 3
)]
df2.hist(ax=ax, color='b', label='post')
# ax.legend(loc='upper right')
# plt.show()
fig, ax = plt.subplots(figsize=(20,20))
df1 = exp[cols][(exp['participant.inflation'] == '1012') & (
exp['participant.day'] < 3
)]
df1.hist(ax=ax, color='r', label='pre')
fig, ax = plt.subplots(figsize=(20,20))
# ax = fig.gca()
df2 = exp[cols][(exp['participant.inflation'] == '1012') & (
exp['participant.day'] >= 3
)]
df2.hist(ax=ax, color='b', label='post')
array([[<AxesSubplot:title={'center':'task.12.player.inf_expectation'}>,
<AxesSubplot:title={'center':'task.24.player.inf_expectation'}>,
<AxesSubplot:title={'center':'task.36.player.inf_expectation'}>],
[<AxesSubplot:title={'center':'task.48.player.inf_expectation'}>,
<AxesSubplot:title={'center':'task.60.player.inf_expectation'}>,
<AxesSubplot:title={'center':'task.72.player.inf_expectation'}>],
[<AxesSubplot:title={'center':'task.84.player.inf_expectation'}>,
<AxesSubplot:title={'center':'task.96.player.inf_expectation'}>,
<AxesSubplot:title={'center':'task.108.player.inf_expectation'}>]],
dtype=object)
plt.subplots()
est['revisions'][(est['participant.inflation'] == '1012') & (
est['participant.day'] < 3
)].hist(color='r', label='10x12 pre-intervention')
est['revisions'][(est['participant.inflation'] == '1012') & (
est['participant.day'] >= 3
)].hist(color='b', alpha = 0.4, label='10x12 post-intervention')
plt.legend(loc='upper left')
plt.subplots()
est['revisions'][(est['participant.inflation'] == '430') & (
est['participant.day'] < 3
)].hist(color='r', label='4x30 pre-intervention')
est['revisions'][(est['participant.inflation'] == '430') & (
est['participant.day'] >= 3
)].hist(color='b', alpha = 0.4, label='4x30 post-intervention')
plt.legend(loc='upper left')
<matplotlib.legend.Legend at 0x24229b8d910>
cols = [c for c in est.columns.to_list() if ('task.' not in c) and ('.day' not in c)]
est[cols].groupby(['participant.inflation', est['participant.day'] < 3]).mean()
| 24-12 | 36-24 | 48-36 | 60-48 | 72-60 | 84-72 | 96-84 | 108-96 | 120-108 | revisions | ||
|---|---|---|---|---|---|---|---|---|---|---|---|
| participant.inflation | participant.day | ||||||||||
| 1012 | False | 18.857143 | -12.704762 | 15.380952 | -12.895238 | 14.333333 | -12.323810 | 18.485714 | -13.714286 | 29.009524 | 8.371429 |
| True | 18.212389 | -10.185841 | 14.761062 | -9.398230 | 11.548673 | -12.309735 | 18.205357 | -13.232143 | 25.250000 | 8.391304 | |
| 430 | False | 0.219048 | 7.933333 | 8.361905 | 6.466667 | -14.704762 | 0.342857 | 6.009524 | 11.161905 | 16.600000 | 7.619048 |
| True | 1.598214 | 8.660714 | 6.464286 | 10.776786 | -14.035714 | -1.419643 | 6.455357 | 10.580357 | 18.125000 | 7.777778 |
plt.subplots()
exp['revisions'][(exp['participant.inflation'] == '1012') & (
exp['participant.day'] < 3
)].hist(color='r', label='10x12 pre-intervention')
exp['revisions'][(exp['participant.inflation'] == '1012') & (
exp['participant.day'] >= 3
)].hist(color='b', alpha = 0.4, label='10x12 post-intervention')
plt.legend(loc='upper left')
plt.subplots()
exp['revisions'][(exp['participant.inflation'] == '430') & (
exp['participant.day'] < 3
)].hist(color='r', label='4x30 pre-intervention')
exp['revisions'][(exp['participant.inflation'] == '430') & (
exp['participant.day'] >= 3
)].hist(color='b', alpha = 0.4, label='4x30 post-intervention')
plt.legend(loc='upper left')
<matplotlib.legend.Legend at 0x2422f4f1730>
cols = [c for c in exp.columns.to_list() if ('task.' not in c) and ('.day' not in c)]
exp[cols].groupby(['participant.inflation', exp['participant.day'] < 3]).describe().T
| participant.inflation | 1012 | 430 | |||
|---|---|---|---|---|---|
| participant.day | False | True | False | True | |
| 24-12 | count | 105.000000 | 113.000000 | 105.000000 | 112.000000 |
| mean | 4.914286 | 16.752212 | 2.095238 | -1.026786 | |
| std | 25.220228 | 22.193762 | 10.407582 | 15.098750 | |
| min | -105.000000 | -27.000000 | -24.000000 | -45.000000 | |
| 25% | -3.000000 | 2.000000 | 0.000000 | -4.250000 | |
| 50% | 3.000000 | 8.000000 | 1.000000 | 0.000000 | |
| 75% | 12.000000 | 26.000000 | 4.000000 | 2.000000 | |
| max | 89.000000 | 95.000000 | 57.000000 | 106.000000 | |
| 36-24 | count | 105.000000 | 113.000000 | 105.000000 | 112.000000 |
| mean | 4.961905 | -3.752212 | 2.990476 | 9.857143 | |
| std | 22.217857 | 21.998186 | 16.688605 | 15.200674 | |
| min | -59.000000 | -110.000000 | -66.000000 | -35.000000 | |
| 25% | -1.000000 | -11.000000 | -1.000000 | 0.750000 | |
| 50% | 1.000000 | 0.000000 | 2.000000 | 7.000000 | |
| 75% | 12.000000 | 6.000000 | 9.000000 | 17.000000 | |
| max | 106.000000 | 61.000000 | 66.000000 | 68.000000 | |
| 48-36 | count | 105.000000 | 113.000000 | 105.000000 | 112.000000 |
| mean | -1.542857 | 2.955752 | 2.247619 | 2.178571 | |
| std | 20.794336 | 16.102013 | 14.671913 | 15.858163 | |
| min | -66.000000 | -49.000000 | -43.000000 | -75.000000 | |
| 25% | -7.000000 | -3.000000 | -1.000000 | -4.250000 | |
| 50% | 1.000000 | 3.000000 | 1.000000 | 3.000000 | |
| 75% | 8.000000 | 12.000000 | 9.000000 | 12.000000 | |
| max | 74.000000 | 55.000000 | 57.000000 | 36.000000 | |
| 60-48 | count | 105.000000 | 113.000000 | 105.000000 | 112.000000 |
| mean | 4.019048 | 2.522124 | 5.028571 | 8.017857 | |
| std | 23.030490 | 22.377483 | 19.515505 | 20.558413 | |
| min | -69.000000 | -72.000000 | -71.000000 | -96.000000 | |
| 25% | -5.000000 | -8.000000 | -1.000000 | -1.250000 | |
| 50% | 0.000000 | 0.000000 | 3.000000 | 3.000000 | |
| 75% | 10.000000 | 8.000000 | 10.000000 | 17.250000 | |
| max | 71.000000 | 100.000000 | 82.000000 | 65.000000 | |
| 72-60 | count | 105.000000 | 113.000000 | 105.000000 | 112.000000 |
| mean | -1.904762 | -1.646018 | -4.152381 | -5.517857 | |
| std | 19.376097 | 21.904387 | 19.614938 | 20.719483 | |
| min | -66.000000 | -77.000000 | -93.000000 | -78.000000 | |
| 25% | -7.000000 | -7.000000 | -9.000000 | -15.000000 | |
| 50% | 1.000000 | 0.000000 | -2.000000 | -1.500000 | |
| 75% | 8.000000 | 5.000000 | 2.000000 | 4.500000 | |
| max | 57.000000 | 65.000000 | 62.000000 | 42.000000 | |
| 84-72 | count | 105.000000 | 113.000000 | 105.000000 | 112.000000 |
| mean | 5.666667 | 3.415929 | 1.980952 | -1.901786 | |
| std | 19.741925 | 21.775939 | 15.160666 | 16.515873 | |
| min | -29.000000 | -58.000000 | -50.000000 | -54.000000 | |
| 25% | -5.000000 | -4.000000 | -4.000000 | -8.000000 | |
| 50% | 0.000000 | 1.000000 | 0.000000 | 0.000000 | |
| 75% | 9.000000 | 10.000000 | 5.000000 | 5.000000 | |
| max | 66.000000 | 80.000000 | 58.000000 | 45.000000 | |
| 96-84 | count | 105.000000 | 112.000000 | 105.000000 | 112.000000 |
| mean | -3.476190 | -1.839286 | 0.314286 | 3.267857 | |
| std | 24.493365 | 26.953598 | 16.731657 | 17.780434 | |
| min | -67.000000 | -94.000000 | -84.000000 | -63.000000 | |
| 25% | -7.000000 | -13.250000 | -3.000000 | -2.000000 | |
| 50% | 0.000000 | 0.000000 | 1.000000 | 3.000000 | |
| 75% | 6.000000 | 8.250000 | 6.000000 | 12.000000 | |
| max | 99.000000 | 63.000000 | 45.000000 | 69.000000 | |
| 108-96 | count | 105.000000 | 112.000000 | 105.000000 | 112.000000 |
| mean | 8.419048 | 4.616071 | 8.380952 | 5.696429 | |
| std | 25.232298 | 24.659938 | 16.802233 | 26.788070 | |
| min | -95.000000 | -66.000000 | -28.000000 | -183.000000 | |
| 25% | -2.000000 | -5.000000 | -1.000000 | -1.250000 | |
| 50% | 3.000000 | 2.000000 | 5.000000 | 1.500000 | |
| 75% | 16.000000 | 11.000000 | 13.000000 | 14.250000 | |
| max | 70.000000 | 99.000000 | 85.000000 | 72.000000 | |
| revisions | count | 105.000000 | 115.000000 | 105.000000 | 117.000000 |
| mean | 7.171429 | 7.391304 | 6.942857 | 7.094017 | |
| std | 1.369005 | 1.226145 | 1.343278 | 1.383293 | |
| min | 0.000000 | 2.000000 | 0.000000 | 1.000000 | |
| 25% | 7.000000 | 7.000000 | 7.000000 | 7.000000 | |
| 50% | 8.000000 | 8.000000 | 7.000000 | 8.000000 | |
| 75% | 8.000000 | 8.000000 | 8.000000 | 8.000000 | |
| max | 8.000000 | 8.000000 | 8.000000 | 8.000000 | |
df = final_df_dict['decision'].copy()
cols = [c for c in df.columns.to_list() if 'task.' in c]
df[cols] = df[cols].astype(float)
fig, ax = plt.subplots(figsize=(30,30))
df1 = df[cols][(df['participant.inflation'] == '1012') & (
df['participant.day'] < 3)]
df1.hist(ax=ax, bins=20, color='r', label='pre')
plt.legend(loc='upper left')
fig, ax = plt.subplots(figsize=(30,30))
df1 = df[cols][(df['participant.inflation'] == '1012') & (
df['participant.day'] >= 3)]
df1.hist(ax=ax, bins=20, color='b', label='post')
plt.legend(loc='upper left')
fig, ax = plt.subplots(figsize=(30,30))
df1 = df[cols][(df['participant.inflation'] == '430') & (
df['participant.day'] < 3)]
df1.hist(ax=ax, bins=20, color='r', label='pre')
plt.legend(loc='upper left')
fig, ax = plt.subplots(figsize=(30,30))
df1 = df[cols][(df['participant.inflation'] == '430') & (
df['participant.day'] >= 3)]
df1.hist(ax=ax, bins=20, color='b', label='post')
plt.legend(loc='upper left')
No handles with labels found to put in legend. No handles with labels found to put in legend. No handles with labels found to put in legend. No handles with labels found to put in legend.
<matplotlib.legend.Legend at 0x2422e88cc40>